/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import basedatos.OperacionesBD;
import basedatos.PymeBD;
import java.io.Serializable;
import java.util.List;
import javax.persistence.*;

/**
 *
 * @author francisco
 */
@Entity
@NamedQueries({
    @NamedQuery(name = "Pyme.findAll", query = "SELECT p FROM Pyme p"),
    @NamedQuery(name = "Pyme.delete", query = "DELETE FROM Pyme p WHERE p.idPyme = :id")
})
public class Pyme implements Serializable {

    @Id
    //@GeneratedValue
    private int idPyme;
    private String ruc;
    private String nombre;
    private String direccion;
    private String telefono;
    private String fax;
    private String celular;
    private String directivo;
    private String eslogan;
    private String url;
    private String mail;

    public Pyme() 
    {
    }

    public int getIdPyme() {return idPyme;}
    public void setIdPyme(int idPyme) {this.idPyme = idPyme;}

    public String getRuc() {return ruc;}
    public void setRuc(String ruc) {this.ruc = ruc;}

    public String getNombre() {return nombre;}
    public void setNombre(String nombre) {this.nombre = nombre;}

    public String getDireccion() {return direccion;}
    public void setDireccion(String direccion) {this.direccion = direccion;}

    public String getTelefono() {return telefono;}
    public void setTelefono(String telefono) {this.telefono = telefono;}
    
    public String getFax() {return fax;}
    public void setFax(String fax) {this.fax = fax;}

    public String getCelular() {return celular;}
    public void setCelular(String celular) {this.celular = celular;}
    
    public String getDirectivo() {return directivo;}
    public void setDirectivo(String directivo) {this.directivo = directivo;}

    public String getEslogan() {return eslogan;}
    public void setEslogan(String eslogan) {this.eslogan = eslogan;}

    public String getUrl() {return url;}
    public void setUrl(String url) {this.url = url;}
    
    public String getMail() {return mail;}
    public void setMail(String mail) {this.mail = mail;}
    ////////////////
    public List<Pyme>  selectPyme() throws Exception
    {
        PymeBD pbd = new PymeBD();
        List<Object> lsObPyme = pbd.listar("Pyme");
        List<Pyme> lspyme = (List)lsObPyme;
        return lspyme;
    }
    
    public boolean insertPyme(Pyme ePyme) throws Exception
    {
         PymeBD pbd = new PymeBD();
         if(pbd.persistir(ePyme)==1)//guardar(pyme))
             return true;
         return false;
    }
    public boolean updatePyme(Pyme pyme) throws Exception
    {
         OperacionesBD obd = new OperacionesBD();
         if(obd.modificar(pyme))
             return true;
         return false;
    }
    public boolean deletePyme(Pyme pyme) throws Exception
    {
        OperacionesBD obd = new OperacionesBD();
        if(obd.eliminar(pyme,pyme.idPyme))
            return true;
        return false;
    }

}
